package com.atxiaodei.pagehelp.mybatispagehelper.controller;


import com.atxiaodei.pagehelp.mybatispagehelper.core.TableDataInfo;
import com.atxiaodei.pagehelp.mybatispagehelper.pojo.Student;
import com.atxiaodei.pagehelp.mybatispagehelper.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangmeng
 * @date 2020/9/22
 **/
@RestController
@Slf4j
@RequestMapping(value = "/api")
public class StudentRestController {

    @Autowired
    private StudentService service;

    @RequestMapping(value = "/student", method = RequestMethod.POST)
    public boolean addStudent(@RequestBody Student student) {
        log.info("开始新增...");
        return service.insert(student);
    }

    @RequestMapping(value = "/student", method = RequestMethod.PUT)
    public boolean updateStudent(@RequestBody Student student) {
        log.info("开始更新...");
        return service.update(student);
    }

    @RequestMapping(value = "/student", method = RequestMethod.DELETE)
    public boolean delete(@RequestBody Student student) {
        log.info("开始删除...");
        return service.delete(student);
    }

    @RequestMapping(value = "/student", method = RequestMethod.GET)
    public TableDataInfo findByStudent(Student student) {
        log.info("开始查询...");
        return service.findByListEntity(student);
    }
}
